package subjectiveQuiz

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method("GET")
        url(value(producer("/api/v3/subjectiveQuizzes/students/1/assignments/1/quizzes/1")
                , consumer(regex("/api/v3/subjectiveQuizzes/students/\\d+/assignments/\\d+/quizzes/\\d+"))))
    }
    response {
        status(200)
        headers {
            contentType(applicationJsonUtf8())
        }
        body("""
        [
                {
                    "id":1,
                    "description":"subjective1",
                    "makerId":1,
                    "referenceNumber":1,
                    "isAvailable":true,
                    "quizGroupId":1,
                    "createTime":"2018-09-12 06:00:00.0",
                    "updateTime":"2018-09-12 06:00:00.0",
                    "remark":"remark1",
                    "tags":[],
                    "userAnswer":"",
                    "answerBranch":""
                }
            ]
        """)
        bodyMatchers {
            jsonPath('$[*]', byType())
            jsonPath('$[*].id', byRegex(number()))
            jsonPath('$[*].description', byRegex("[\\s\\S]+"))
            jsonPath('$[*].makerId', byRegex(number()))
            jsonPath('$[*].referenceNumber', byRegex(number()))
            jsonPath('$[*].isAvailable', byRegex(anyBoolean()))
            jsonPath('$[*].quizGroupId', byRegex(number()))
            jsonPath('$[*].createTime', byRegex("[\\s\\S]+"))
            jsonPath('$[*].updateTime', byRegex("[\\s\\S]+"))
            jsonPath('$[*].remark', byRegex("[\\s\\S]+"))
            jsonPath('$[*].tags', byType())
            jsonPath('$[*].userAnswer', byType())
            jsonPath('$[*].answerBranch', byType())
        }
    }
}
